//
//  SYRequestAPI+FuDao.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/5/15.
//  Copyright © 2019年 SanYi. All rights reserved.
//

//问题辅导
NSString *const kSYFDWenTiBaseUrl = @"tutor/QuestionTutorService.svc/";
//分组管理
NSString *const kSYFDWenTiFenZuUrl = @"/tutor/QuestionSortService.svc/";
//在线辅导
NSString *const kSYFDZaiXianUrl = @"/tutor/OnLineTutorService.svc/";
//班级管理TutorClassService
NSString *const kSYFDBanJiUrl = @"tutor/TutorClassService.svc/";
//补课管理
NSString *const kSYFDXianShangUrl = @"/tutor/LessonTutorService.svc/";
//补课信息
NSString *const kSYFDBuKeXinXiUrl = @"/tutor/LessonTutorInfoService.svc/";
//补课管理
NSString *const kSYFDXianXiaSHengQingURL = @"/tutor/LessonTutorService.svc/";

//NSString *const kSYFDShangKeDianMingURL = @"/tutor/LessonTutorService.svc/";



#import "SYRequestAPI+FuDao.h"
#import "SYFuDaoModel.h"
#import "BuKeXiangQIngModel.h"
#import "SYGroupChatDetailModel.h"



@implementation SYRequestAPI (FuDao)
//问题列表
+ (void)fd_requestTutorQuestionTutorServiceIsAnswer:(NSString *)isAnswer
                                            keyword:(NSString *)keyword
                                            classId:(NSString *)classId
                                          pageIndex:(NSInteger)pageIndex
                                           pageSize:(NSInteger)pageSize
                                            success:(void(^)(NSMutableArray *listArr))success
                                               fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiBaseUrl, @"QuestionList");
    
    NSDictionary *dict = @{
                           @"pageIndex":SJStringWithFormat(pageIndex),
                           @"pageSize":SJStringWithFormat(pageSize),
                           @"keyword":keyword,
                           @"isAnswer":isAnswer,
                           @"classId":classId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        for (NSDictionary *dict in listArr) {
            SYWenTiFuDaoModel *wtfd = [SYWenTiFuDaoModel yy_modelWithDictionary:dict];
            wtfd.headIng = dict[@"headImg"];
            [dataArr addObject:wtfd];
        }
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

//问题分组
+ (void)fd_requestQuestionSortQuestionId:(NSString *)questionId
                                  sortId:(NSString *)sortId
                               oldSortId:(NSString *)oldsortid
                                 success:(void(^)(BOOL isSuccess))success
                                    fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiBaseUrl, @"QuestionSort");
    
    NSDictionary *dict = @{
                           @"questionId":questionId,
                           @"sortId":sortId,
                           @"oldSortId":oldsortid,
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
       
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//分类问题
+ (void)fd_requestFenZuQuestionSortListSortId:(NSString *)sortId
                                      keyWord:(NSString *)keyWord
                                    pageIndex:(NSInteger)pageIndex
                                     pageSize:(NSInteger)pageSize
                                      success:(void(^)(NSMutableArray *listArr))success
                                         fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiBaseUrl, @"QuestionSortList");
    
    NSDictionary *dict = @{
                           @"sortId":sortId,
                           @"keyWord":keyWord,
                           @"pageIndex":SJStringWithFormat(pageIndex),
                           @"pageSize":SJStringWithFormat(pageSize)
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        for (NSDictionary *dict in listArr) {
            SYWenTiDetailsModel *wtfd = [SYWenTiDetailsModel yy_modelWithDictionary:dict];
            [dataArr addObject:wtfd];
        }
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//问题删除
+ (void)fd_requestQuestionDeleteQuestionId:(NSString *)questionId
                                   success:(void(^)(BOOL isSuccess))success
                                      fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiBaseUrl, @"QuestionDelete");
    
    NSDictionary *dict = @{
                           @"questionId":questionId,
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//问题收藏
+ (void)fd_requestQuestionCollectionQuestionId:(NSString *)questionId
                                       success:(void(^)(BOOL isSuccess))success
                                          fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiBaseUrl, @"QuestionCollection");
    
    NSDictionary *dict = @{
                           @"questionId":questionId,
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
+ (void)fd_requestQuestionDetailQuestionId:(NSString *)questionId
                                   success:(void(^)(NSMutableArray *listArr))success
                                      fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiBaseUrl, @"QuestionDetail");
    
    NSDictionary *dict = @{
                           @"questionId":questionId,
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSDictionary *listArr = responseObject[@"data"];

            SYWenTiDetailsModel *wtfd = [SYWenTiDetailsModel yy_modelWithDictionary:listArr];
            [dataArr addObject:wtfd];
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//分组问题
+ (void)fd_requestFenZuQuestionSortKeyWord:(NSString *)keyWord
                                   success:(void(^)(NSMutableArray *listArr))success
                                      fail:(FailBlock)fail
{
    
    NSString *url = SYStringWithPickFormat(kSYFDWenTiFenZuUrl, @"QuestionSort");
    
    NSDictionary *dict = @{
                           @"keyWord":keyWord,
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        for (NSDictionary *dict in listArr) {
            SYWenTiFenZuModel *wtfd = [SYWenTiFenZuModel yy_modelWithDictionary:dict];
            [dataArr addObject:wtfd];
        }
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
    
    
}


+ (void)fd_requestFenZuSortAddId:(NSString *)fzId
                            name:(NSString *)name
                          remark:(NSString *)remark
                         success:(void(^)(BOOL isSuccess))success
                            fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiFenZuUrl, @"SortAdd");
    
    NSDictionary *dict = @{
                           @"id":fzId,
                           @"name":name,
                           @"remark":remark
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//删除
+ (void)fd_requestFenZuSorDeleteId:(NSString *)deleteid
                          isDelete:(NSString *)isDelete
                           success:(void(^)(BOOL isSuccess))success
                              fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiFenZuUrl, @"SortModi");
    
    NSDictionary *dict = @{
                           @"id":deleteid,
                           @"isDelete":@"0"
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//分组合并
+ (void)fd_requestFenZuSorQuestionBatchTransFerSortId:(NSString *)sortId
                                            oldSortId:(NSString *)oldSortId
                                              success:(void(^)(BOOL isSuccess))success
                                                 fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDWenTiFenZuUrl, @"QuestionBatchTransfer");
    
    NSDictionary *dict = @{
                           @"sortId":sortId,
                           @"oldSortId":oldSortId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}


#pragma mark - 在线辅导
+ (void)fd_requestClassListClassId:(NSString *)classid
                              date:(NSString *)date
                           keyWord:(NSString *)keyWord
                        ifFinished:(NSString *)isfinished
                           success:(void(^)(NSMutableArray *listArr))success
                              fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDZaiXianUrl, @"ClassList");
    
    NSDictionary *dict = @{
                           @"keyWord":keyWord,
                           @"isFinished":isfinished,
                           @"classId":classid,
                           @"date":date
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        for (NSDictionary *dict in listArr) {
            SYZaiXianFuDaoModel *zxfd = [SYZaiXianFuDaoModel yy_modelWithJSON:dict];
            [dataArr addObject:zxfd];
        }
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

#pragma mark - 班级
+ (void)fd_requestZaiXianClassDetailsClassId:(NSString *)classId
                                     success:(void(^)(NSMutableArray *listArr))success
                                        fail:(FailBlock)fail
{
    
    NSString *url = SYStringWithPickFormat(kSYFDBanJiUrl, @"ClassDetail");
    
    NSDictionary *dict = @{
                           @"classId":classId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSDictionary *dataDict = responseObject[@"data"];
        SYBanJiDetails *zxfd = [SYBanJiDetails yy_modelWithJSON:dataDict];
        zxfd.dataTutorArr = [NSMutableArray array];//辅导信息
        zxfd.dataStudentArr = [NSMutableArray array];//班级学生
        zxfd.dataResourceArr = [NSMutableArray array];
        NSArray *dataTutor = dataDict[@"dataTutor"];
        for (NSDictionary *tutorDict in dataTutor) {
            SYDataTutorModel *tutorModel = [SYDataTutorModel yy_modelWithDictionary:tutorDict];
            [zxfd.dataTutorArr addObject:tutorModel];
        }
        
        NSArray *dataStudent = dataDict[@"dataStudent"];
        for (NSDictionary *studentDict in dataStudent) {
            SYDataStudent *studentModel = [SYDataStudent yy_modelWithDictionary:studentDict];
            [zxfd.dataStudentArr addObject:studentModel];
        }
        
        NSArray *dataResourceArr = dataDict[@"dataResource"];
        
        for (NSDictionary *dataResourceDict in dataResourceArr) {
            SYDataResourceModel *resourceModel = [SYDataResourceModel yy_modelWithJSON:dataResourceDict];
            resourceModel.dataResourceFile = [NSMutableArray array];
            NSArray *fileArr =dataResourceDict[@"dataResourceFile"];
            for (NSDictionary *resourceFile in fileArr) {
                SYDataResourceFileModel *fileModel = [SYDataResourceFileModel yy_modelWithDictionary:resourceFile];
                [resourceModel.dataResourceFile addObject:fileModel];
            }
            [zxfd.dataResourceArr addObject:resourceModel];
        }
        
        [dataArr addObject:zxfd];
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//6.5.4.9    辅导视频查看记录
+ (void)fd_requestZaiXianClassTutorRecordClassId:(NSString *)classId
                                         success:(void(^)(NSMutableArray *listArr))success
                                            fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDBanJiUrl, @"ClassTutorViewRecord");
//    ClassTutorViewRecord
    NSDictionary *dict = @{
                           @"classId":classId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
//        NSLog(@"得到辅导视频观看记录 %@",responseObject);
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        
        NSDictionary *dataDict = responseObject[@"data"];
        SYPlayerClassModel *zxfd = [SYPlayerClassModel yy_modelWithJSON:dataDict];
        zxfd.dataTutorArr = [NSMutableArray array];
        
        NSArray *dataTutor = dataDict[@"dataTutor"];
        for (NSDictionary *tutorDict in dataTutor) {
            SYDataTutorModel *tutorModel = [SYDataTutorModel yy_modelWithJSON:tutorDict];
            tutorModel.dataStudentArr = [NSMutableArray array];
            NSArray *tutorViewArr = tutorDict[@"dataTutorView"];
            for (NSDictionary *tutorViewDict in tutorViewArr) {
                SYDataStudent *tutorViewModel = [SYDataStudent yy_modelWithJSON:tutorViewDict];
                [tutorModel.dataStudentArr addObject:tutorViewModel];
            }
            [zxfd.dataTutorArr addObject:tutorModel];
        }
        
        [dataArr addObject:zxfd];

        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//6.5.4.1    创建班级/修改班级
+ (void)fd_requestZaiXianAddFuDaoClassId:(NSString *)fdId
                                   title:(NSString *)title
                                 classId:(NSString *)classId
                               accountId:(NSString *)accountId
                          tutorAccountId:(NSString *)tutorAccountId
                                    type:(NSString *)type
                              tutorType:(NSString *)tutorType
                              tutorTimes:(NSString *)tutorTimes
                               beginDate:(NSString *)beginDate
                                 endDate:(NSString *)endDate
                                 content:(NSString *)content
                                   msgId:(NSString *)msgId
                              isFinished:(NSString *)finished
                                 success:(void(^)(id responseObject))success
                                    fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDBanJiUrl, @"ClassAddNew");
    NSString *imid = [USERDEFAL objectForKey:RYIMidIDDefalut];

    NSDictionary *dict = @{
                           @"id":fdId,
                           @"title":title,
                           @"classId":classId,
                           @"accountId":accountId,
//                           @"tutorAccountId":@"0",
                           @"templateId":tutorAccountId.length>0?tutorAccountId:@"0",
                           @"type":type,
                           @"tutorTimes":tutorTimes,
                           @"beginDate":beginDate,
                           @"endDate":endDate,
                           @"content":content,
                           @"tutorType":tutorType,
                           @"imid":imid,
                           @"msgId":msgId,
                           @"isFinished":finished
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
//        NSLog(@"创建班级 %@",responseObject);
        if (success) {
           // NSDictionary *data = [responseObject objectForKey:@"data"];
            success(responseObject);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

//6.5.5.1    线上申请列表
+ (void)fd_requestLessonTutorLessonLineApplyIsOnLine:(NSString *)isOnLine
                                             classId:(NSString *)classId
                                                date:(NSString *)date
                                             keyWord:(NSString *)keyWord
                                           pageIndex:(NSInteger)pageIndex
                                            pageSize:(NSInteger)pageSize
                                             success:(void(^)(NSMutableArray *listArr))success
                                                fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDXianShangUrl, @"TutorLessonOnLineApply");
    
    NSDictionary *dict = @{
                           @"isOnLine":isOnLine,
                           @"classId":classId,
                           @"date":date,
                           @"keyWord":keyWord,
                           @"pageIndex":SJStringWithFormat(pageIndex),
                           @"pageSize":SJStringWithFormat(pageSize)
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        for (NSDictionary *dict in listArr) {
            SYBuKeGuLiModel *zxfd = [SYBuKeGuLiModel yy_modelWithJSON:dict];
            [dataArr addObject:zxfd];
        }
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//6.5.5.1    线下申请列表
+ (void)fd_requestLessonTutorLessonLineApplyIsOffLine:(NSString *)isOnLine
                                              classId:(NSString *)classId
                                                 date:(NSString *)date
                                              keyWord:(NSString *)keyWord
                                            pageIndex:(NSInteger)pageIndex
                                             pageSize:(NSInteger)pageSize
                                              success:(void(^)(NSMutableArray *listArr))success
                                                 fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDXianShangUrl, @"TutorLessonOffLineApply");
    
    NSDictionary *dict = @{
                           @"isOnLine":isOnLine,
                           @"courseId":classId,
                           @"date":date,
                           @"keyWord":keyWord,
                           @"pageIndex":SJStringWithFormat(pageIndex),
                           @"pageSize":SJStringWithFormat(pageSize)
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        if ([isOnLine isEqualToString:@"0"]) {
            NSLog(@"结果 %@",responseObject);
        }
        for (NSDictionary *dict in listArr) {
            XianXiaShengQingAllModel *zxfd = [XianXiaShengQingAllModel yy_modelWithJSON:dict];
            NSMutableArray *array = [NSMutableArray new];
            for (NSDictionary *dic in zxfd.dataLesson) {
                DataLessonModel *dlm = [DataLessonModel yy_modelWithJSON:dic];
                [array addObject:dlm];
            }
            zxfd.dataLesson = array;
            [dataArr addObject:zxfd];
        }
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//6.5.5.2    资源发放查看
+ (void)fd_requestLessonTutorLessonApplyId:(NSString *)applyId
                                  courseId:(NSString *)courseId
                                      date:(NSString *)date
                                   keyWord:(NSString *)keyWord
                                  isOnLine:(NSString *)isOnLine
                                   success:(void(^)(NSMutableArray *listArr))success
                                      fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDXianShangUrl, @"TutorLessonOnLineView");
    
    NSDictionary *dict = @{
                           @"isOnLine":isOnLine,
                           @"courseId":courseId,
                           @"applyIds":applyId,
                           @"keyWord":keyWord,
                           @"date":date
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        
        for (NSDictionary *dict in listArr) {
            SYBuKeGuLiModel *zxfd = [SYBuKeGuLiModel yy_modelWithJSON:dict];
            zxfd.dataResourceArr = [NSMutableArray array];
            for (NSDictionary *fileDict in dict[@"dataResourceFile"]) {
                SYDataResourceFileModel *dataModel = [SYDataResourceFileModel yy_modelWithDictionary:fileDict];
                [zxfd.dataResourceArr addObject:dataModel];
            }
            
            [dataArr addObject:zxfd];
        }
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//6.5.5.3    资源发放保存
+ (void)fd_requestLessonTutorLessonLineSaveIsOnLine:(NSString *)isOnLine
                                           applyIds:(NSString *)applyIds
                                          grandDate:(NSString *)grandDate
                                        recycleDate:(NSString *)recyeleDate
                                            success:(void(^)(BOOL isSuccess))success
                                               fail:(FailBlock)fail
{
//    NSString *url = SYStringWithPickFormat(kSYFDXianShangUrl, @"TutorLessonOnLineSave");
    
//    NSDictionary *dict = @{
//                           @"isOnLine":isOnLine,
//                           @"applyIds":applyIds,
//                           @"grandDate":grandDate,
//                           @"recycleDate":recyeleDate
//                           };
    NSString *url = @"tutor/LessonTutorService.svc/TutorLessonOnLineSaveNew";
    NSDictionary *dict = @{
    @"lessonApplyId":applyIds,
    @"grandDate":grandDate,
    @"recycleDate":recyeleDate
    };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

+ (void)fd_requestLessonTutorLessonListIsOnLine:(NSString *)isOnLine
                                        classId:(NSString *)classId
                                           date:(NSString *)date
                                        keyWord:(NSString *)keyWord
                                      pageIndex:(NSInteger)pageIndex
                                       pageSize:(NSInteger)pageSize
                                        success:(void(^)(NSMutableArray *listArr))success
                                           fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFDBuKeXinXiUrl, @"TutorLessonList");
    
    NSDictionary *dict = @{
                           @"isOnLine":isOnLine,
                           @"classId":classId,
                           @"date":date,
                           @"keyWord":keyWord,
                           @"pageIndex":SJStringWithFormat(pageIndex),
                           @"pageSize":SJStringWithFormat(pageSize)
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        
        for (NSDictionary *dict in listArr) {
            SYBuKeXinXiModel *zxfd = [SYBuKeXinXiModel yy_modelWithJSON:dict];
            
            
            [dataArr addObject:zxfd];
        }
        if (success) {
            success(dataArr);
        }
       
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

//6.5.6.2    线上补课详情
+ (void)fd_requestLessonTutorLessonLineDetailsTutorAppleyId:(NSString *)appleyId
                                                   isOnLine:(NSString *)isOnLine
                                                    success:(void(^)(SYBuKeDetailsModel *listArr))success
                                                       fail:(FailBlock)fail
{
    
    
//    NSString *jiekou
    
    NSString *url = SYStringWithPickFormat(kSYFDBuKeXinXiUrl, @"TutorLessonOnLineDetail");
    
    
    
    NSDictionary *dict = @{
                           @"isOnLine":[isOnLine isEqualToString:@"是"]?@"1":@"0",
                           @"tutorApplyId":appleyId,
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {

        NSDictionary *data = responseObject[@"data"];
        NSMutableArray *dataResourceFileArr = [NSMutableArray array];//资源包
//        NSMutableArray *dataStudents = [NSMutableArray array];//学生
        
            SYBuKeDetailsModel *detailsModel = [[SYBuKeDetailsModel alloc] init];

//            // YLSLog(@"得到补课详情数据 %@",responseObject);
//            NSMutableArray *dataArr = [[NSMutableArray alloc] init];
//            NSDictionary *listDic = responseObject[@"data"];
//            BuKeXiangQIngModel *model = [BuKeXiangQIngModel yy_modelWithJSON:[listDic objectForKey:@"dataResource"]];
//            model.dataResourceFileArray = [NSMutableArray new];
//            for (NSDictionary *dict in model.dataResourceFile) {
//                DataResourceFileModel *m = [DataResourceFileModel yy_modelWithJSON:dict];
//                [model.dataResourceFileArray addObject:m];
//            }
//            SataStudentsModel *sm = [SataStudentsModel yy_modelWithJSON:[listDic objectForKey:@"dataStudents"]];
//            [dataArr addObject:model];
//            // [dataArr addObject:sm];
//            if (success) {
//                success(dataArr);
//            }
        
        

        SYDataResourceModel *resourceModel = [SYDataResourceModel yy_modelWithJSON:data[@"dataResource"]];
        

        for (NSDictionary *dict in data[@"dataResource"][@"dataResourceFile"]) {
            SYDataResourceFileModel *dataResourceFile = [SYDataResourceFileModel yy_modelWithJSON:dict];
            [dataResourceFileArr addObject:dataResourceFile];
        }
        resourceModel.dataResourceFile = dataResourceFileArr;
        detailsModel.dataResource = resourceModel;
        
        
        if (success) {
            success(detailsModel);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}


//6.5.5.5线下申请列表
//acsafcfavcvasc//
+ (void)fd_TutorTutorClassServiceTutorLessonOffLineApply:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    NSString *url = SYStringWithPickFormat(kSYFDXianXiaSHengQingURL, @"TutorLessonOnLineApply");
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:parama success:^(id responseObject) {
        // NSLog(@"//acsafcfavcvasc//线下申请成功败 %@",responseObject);
        if (success) {
            success(responseObject);
        }
    } fail:^(NSError *error) {
        if (error) {
            NSLog(@"//acsafcfavcvasc//线下申请失败 %@",error.message);
            fail(error);
        }
    }];
}
//6.5.5.7上课点名列表
+ (void)fd_TutorTutorClassServiceTutorLessonOffLineSign:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    NSString *url = SYStringWithPickFormat(kSYFDXianXiaSHengQingURL, @"TutorLessonOffLineSign");
    NSLog(@"输出上课点名列表参数 %@  %@",url,parama);
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:parama success:^(id responseObject) {
        if (success) {
            success(responseObject);
        }
    } fail:^(NSError *error) {
//        if (error) {
            NSLog(@"线下申请-上课点名-失败 %@",error.message);
            fail(error);
//        }
    }];
}
//6.5.5.6 查看学生
+ (void)fd_TutorTutorClassServiceTutorLessonOffLineStudents:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    NSString *url = SYStringWithPickFormat(kSYFDXianXiaSHengQingURL, @"TutorLessonOffLineStudents");
  ////  NSLog(@"输出上课点名列表参数 %@  %@",url,parama);
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:parama success:^(id responseObject) {
        if (success) {
            success(responseObject);
        }
    } fail:^(NSError *error) {
        //        if (error) {
        NSLog(@"线下申请-上课点名-查看学生-失败 %@",error.message);
        fail(error);
        //        }
    }];
}

//6.5.4.2 申请资源
+ (void)fd_TutorTutorClassServiceClassAdd:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    NSString *url = SYStringWithPickFormat(kSYFDBanJiUrl, @"ResourceApply");
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:parama success:^(id responseObject) {
        if (success) {
            success(responseObject);
        }
    } fail:^(NSError *error) {
        //        if (error) {
        NSLog(@"线下申请-申请资源-失败 %@",error.message);
        fail(error);
        //        }
    }];
}

//选择辅导类型
+ (void)fd_TutorTutorTutorType:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    NSString *url = SYStringWithPickFormat(kSYFDZaiXianUrl, @"TutorTypes");
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:parama success:^(id responseObject) {
        if (success) {
            success(responseObject);
        }
    } fail:^(NSError *error) {
        //        if (error) {
        NSLog(@"辅导类行-失败 %@",error.message);
        fail(error);
        //        }
    }];
}
//创建课时
+ (void)fd_TutorTutorTutorTypeClassLessonAdd:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    NSString *url = SYStringWithPickFormat(kSYFDBanJiUrl, @"ClassLessonAdd");
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:parama success:^(id responseObject) {
        if (success) {
            success(responseObject);
        }
    } fail:^(NSError *error) {
         if (error) {
             NSLog(@"辅导类行-失败 %@",error.message);
             fail(error);
         }
    }];
}
+ (void)fd_TutorTutorClassStudentAdd:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    NSString *url = SYStringWithPickFormat(kSYFDBanJiUrl, @"ClassStudentAdd");
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:parama success:^(id responseObject) {
        if (success) {
            success(responseObject);
        }
    } fail:^(NSError *error) {
        if (error) {
            NSLog(@"添加学生-失败 %@",error.message);
            fail(error);
        }
    }];
}

+ (void)fd_getTemplateInfoByClassId:(NSString *)classId
                            success:(void(^)(NSMutableArray *datalistArr))success
                               fail:(FailBlock)fail
{
    NSDictionary *dict = @{@"ClassId":classId};
    NSString *url = SYStringWithPickFormat(@"tutor/TutorClassService.svc/", @"GetTemplateInfoByClassId");
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataListArr = [NSMutableArray array];
        NSArray *data = responseObject[@"data"];
        for (NSDictionary *dic in data) {
            SYKaoShiModel *ksModel = [SYKaoShiModel yy_modelWithDictionary:dic];
            [dataListArr addObject:ksModel];
        }
        if (success) {
            success(dataListArr);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
//辅导班级删除
+ (void)fd_postTutorClassDeleteTutorId:(NSString *)tutorId
                               success:(void(^)(BOOL isSuccess))success
                                  fail:(FailBlock)fail
{
    NSDictionary *dict = @{@"tutorId":tutorId};
    NSString *url = @"tutor/TutorClassService.svc/TutorClassDelete";
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
//保存视频
+ (void)fd_postTutorClassServiceSaveVideoTutorId:(NSString *)tutorId
                                        recordId:(NSString *)recordId
                                        videoUrl:(NSString *)videoUrl
                                         success:(void(^)(BOOL isSuccess))success
                                            fail:(FailBlock)fail
{
    NSDictionary *dict = @{@"tutorId":tutorId,
                           @"tutorRecordId":recordId,
                           @"videoUrl":videoUrl
                           };
    NSString *url = @"tutor/TutorClassService.svc/SaveVideo";
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
    
}

#pragma mark ------------  群聊辅导详情
+ (void)fd_requestGroupChatClassDetailsClassId:(NSString *)classId
                                     success:(void(^)(NSMutableArray *listArr))success
                                        fail:(FailBlock)fail
{
    
    NSString *url = SYStringWithPickFormat(kSYFDBanJiUrl, @"ClassDetail");
    
    NSDictionary *dict = @{
                           @"classId":classId
                           };
//#import "SYGroupChatDetailModel.h"

    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSDictionary *dataDict = responseObject[@"data"];
//        SYBanJiDetails *zxfd = [SYBanJiDetails yy_modelWithJSON:dataDict];
        SYGroupChatDetailModel *zxfd = [SYGroupChatDetailModel mj_objectWithKeyValues:dataDict];
//        zxfd.dataTutorArr = [NSMutableArray array];//辅导信息
//        zxfd.dataStudentArr = [NSMutableArray array];//班级学生
//        zxfd.dataResourceArr = [NSMutableArray array];
//        NSArray *dataTutor = dataDict[@"dataTutor"];
//        for (NSDictionary *tutorDict in dataTutor) {
//            SYDataTutorModel *tutorModel = [SYDataTutorModel yy_modelWithDictionary:tutorDict];
//            [zxfd.dataTutorArr addObject:tutorModel];
//        }
//
//        NSArray *dataStudent = dataDict[@"dataStudent"];
//        for (NSDictionary *studentDict in dataStudent) {
//            SYDataStudent *studentModel = [SYDataStudent yy_modelWithDictionary:studentDict];
//            [zxfd.dataStudentArr addObject:studentModel];
//        }
        
//        NSArray *dataResourceArr = dataDict[@"dataResource"];
//        
//        for (NSDictionary *dataResourceDict in dataResourceArr) {
//            SYDataResourceModel *resourceModel = [SYDataResourceModel yy_modelWithJSON:dataResourceDict];
//            resourceModel.dataResourceFile = [NSMutableArray array];
//            NSArray *fileArr =dataResourceDict[@"dataResourceFile"];
//            for (NSDictionary *resourceFile in fileArr) {
//                SYDataResourceFileModel *fileModel = [SYDataResourceFileModel yy_modelWithDictionary:resourceFile];
//                [resourceModel.dataResourceFile addObject:fileModel];
//            }
//            [zxfd.dataResourceArr addObject:resourceModel];
//        }
        
        [dataArr addObject:zxfd];
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

//补课邀请列表
+ (void)fd_requestClassLessonInvitationListClassId:(NSString *)classId
                                         pageIndex:(NSString *)pageIndex
                                          pageSize:(NSString *)pageSize
                                           success:(void(^)(NSMutableArray *listArr))success
                                              fail:(FailBlock)fail
{
    NSString *url = @"tutor/LessonTutorService.svc/GetClassLessonInvitationList";
    NSDictionary *dict = @{@"classId":classId,
                           @"pageIndex":pageIndex,
                           @"pageSize":pageSize
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success([responseObject nilObjectForKey:@"data"]);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
    
}
//需要补课的课时列表
+ (void)fd_requestClassNeedLessonListClassId:(NSString *)classId
                                     success:(void(^)(NSMutableArray *listArr))success
                                        fail:(FailBlock)fail
{
    NSString *url = @"tutor/LessonTutorService.svc/GetClassNeedLessonList";
    NSDictionary *dict = @{@"classId":classId,
                           
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success([responseObject nilObjectForKey:@"data"]);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
/**
 分校信息
 
 @param success 1
 @param fail 0
 */
+ (void)fd_requestCampusListSuccess:(void(^)(NSMutableArray *listArr))success
                               fail:(FailBlock)fail
{
    NSString *url = @"common/CommonService.svc/GetCampusList";
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:nil success:^(id responseObject) {
        if (success) {
            success([responseObject nilObjectForKey:@"data"]);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}



/**
 分校班级信息
 
 @param campusId 分校id
 @param nameStr 名字
 @param success 1
 @param fail 0
 */
+ (void)fd_requestClassByCampusListCampusId:(NSString *)campusId
                                       name:(NSString *)nameStr
                                    success:(void(^)(NSMutableArray *listArr))success
                                       fail:(FailBlock)fail
{
    NSString *url = @"common/CommonService.svc/GetClassByCampusList";
    NSDictionary *dict = @{@"campusId":campusId,
                           
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success([responseObject nilObjectForKey:@"data"]);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}

+ (void)fd_requestClassLessonNoAttendStudentListClassId:(NSString *)classId
                                             scheduleId:(NSString *)scheduleId
                                                success:(void(^)(NSMutableArray *listArr))success
                                                   fail:(FailBlock)fail
{
    NSString *url = @"tutor/LessonTutorService.svc/GetClassLessonNoAttendStudentList";
    NSDictionary *dict = @{@"classId":classId,
                           @"scheduleId":scheduleId
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success([responseObject nilObjectForKey:@"data"]);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
+ (void)fd_requestClassInviteStudentSudentIds:(NSString *)student
                                      classId:(NSString *)classid
                                     courseId:(NSString *)courseId
                                   scheduleiD:(NSString *)scheduleiD
                                  lessonTimes:(NSString *)lessonTimes
                                      success:(void(^)(BOOL isOk))success
                                         fail:(FailBlock)fail
{
    NSString *url = @"tutor/LessonTutorService.svc/InviteStudent";
    NSDictionary *dict = @{@"studentIds":student,
                           @"classId":classid,
                           @"courseId":courseId,
                           @"scheduleId":scheduleiD,
                           @"lessonTimes":lessonTimes
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}

+ (void)fd_requestClassGrantVideoStudentId:(NSString *)studentId
                                scheduleId:(NSString *)scheduleId
                                   success:(void(^)(BOOL isOk))success
                                      fail:(FailBlock)fail
{
    NSString *url = @"tutor/LessonTutorService.svc/GrantVideo";
    NSDictionary *dict = @{@"studentId":studentId,
                           @"scheduleId":scheduleId
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}


@end































